<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Web_config extends MY_Controller
{
	function __construct()
	{
		parent::__construct();
		
		// 后台登录验证
		$this->check_login();
		
		// 验证权限
		$this->verify_purview(PURVIEW_WEB);
		
		$this->load->model('web_config_m');
		
		// 加载管理员的放言包
		$this->load->language('web_config');
		
	}
	
	function index()
	{
		$this->edit();
	}
	
	function edit()
	{
		// 获得网站配置的数组
		$config_arr = $this->web_config_m->get_web_config();
		$data = array (
			
				'header' => $this->header,
				'title' => $this->lang->line('web_config_title'),
				'page_label' => $this->lang->line('web_config_label'),
				'nav_label' => $this->lang->line('com_navigate_label'),
				'basic_title' => $this->lang->line('web_config_basic_title'),
				'system_title' => $this->lang->line('web_config_system_title'),
				'config' => $config_arr 
		);
		$this->load->view('web_config', $data);
	}
	
	function edit_action()
	{
		$web_config = $this->input->post();
		if ($web_config && isset($web_config['s_web_config_action']))
		{
			// 处理提交的网站信息;
			unset($web_config['s_web_config_action']);
			foreach ($web_config as $key => $value)
			{
				//$config_arr[] = array('skey' => $key, 'svalue' => $value);
				$this->web_config_m->update_config(array('skey' => $key), array('svalue' => $value));
			}
			//$this->web_config_m->update_config_batch($config_arr,'skey');
			$this->_show_message(base_url('web_config'), $this->lang->line('msg_operation_success'));
		}
		else
		{
			$this->_show_message(base_url('web_config'), $this->lang->line('error_invalid_post'));
		}
	}
}

/* End of file web_config.php */
/* Location: ./application/admin/controllers/web_config.php */
